home *** CD-ROM | disk | FTP | other *** search
/ CD ROM Paradise Collection 4 / CD ROM Paradise Collection 4 1995 Nov.iso / program / swagg_m.zip / GRAPHICS.SWG / 0068_Misc Graphic Functions.pas < prev    next >
Pascal/Delphi Source File  |  1994-01-27  |  6KB  |  146 lines

  1. UNIT GrStuff;       {  Misc Graphic Functions, Last Updated  Nov 11/93 }
  2.                     {  Copyright (C), Greg Estabrooks, 1993            }
  3.  
  4. INTERFACE
  5. (***********************************************************************)
  6.  
  7. FUNCTION MonitorType :BYTE;               {  Determines Monitor In Use  }
  8. PROCEDURE SetVidMode( Mode :BYTE );       {  Set video mode             }
  9. PROCEDURE SetPage( Page :BYTE );          {  Set current screen page    }
  10. PROCEDURE BiosPutPix( Col,Page :BYTE;X,Y :WORD ); { Plot pixel at X,Y   }
  11. FUNCTION TSeng :BOOLEAN;        {  Determine if graph card a TSENG labs }
  12. FUNCTION GetVideoMode :BYTE;
  13.                       {  Routine to determine current video mode        }
  14. PROCEDURE Set80x30Mode;
  15. PROCEDURE DrawBar( X1,Y1,X2,Y2 :WORD; Color :BYTE );
  16. PROCEDURE SetColor( Color2Set, Red, Green, Blue :BYTE );
  17. PROCEDURE GetColor( Color2Get :BYTE; VAR Red,Green,Blue :BYTE );
  18.  
  19. IMPLEMENTATION
  20. (***********************************************************************)
  21. FUNCTION MonitorType :BYTE; ASSEMBLER;
  22.                            {  Determines Type of Monitor In Use.        }
  23. ASM
  24.   Mov AH,$1A                    {  Function Determine Display Code      }
  25.   Mov AL,0                      {  AL,0 = Read Code  AL,1 = Set Code    }
  26.   Int $10                       {  Call Dos                             }
  27.   Mov AL,BL;                    {  Move result to proper register       }
  28.         {  0 - no Display       4 - Ega Standard Color     7 - VGA MONO }
  29.         {  1 - MDA              5 - Ega MonoChrome         8 - VGA      }
  30.         {  2 - CGA              6 - PGA                                 }
  31. END;{MonitorType}
  32.  
  33. PROCEDURE SetVidMode( Mode :BYTE ); ASSEMBLER;
  34.                 {  Routine to set video mode                            }
  35. ASM
  36.   Mov AH,00                     {  Function to set mode                 }
  37.   Mov AL,Mode                   {  Mode to change to                    }
  38.   Int $10                       {  Call dos                             }
  39. END;{SetVidMode}
  40.  
  41. PROCEDURE SetPage( Page :BYTE ); ASSEMBLER;
  42.                 {  Routine to change screen pages                       }
  43. ASM
  44.   Mov AH,$05                    {  Function to change pages             }
  45.   Mov AL,Page                   {  Page to change to                    }
  46.   Int $10                       {  Call dos                             }
  47. END;{SetPage}
  48.  
  49. PROCEDURE BiosPutPix( Col,Page :BYTE; X,Y :WORD ); ASSEMBLER;
  50.                 {  Routine to plot a pixel on the screen using INT 10h. }
  51. ASM
  52.   Mov AH,$0C                    {  Function to plot a pixel             }
  53.   Mov AL,Col                    {  Color to make it                     }
  54.   Mov BH,Page;                  {  Page to write it to                  }
  55.   Mov CX,X                      {  Column to put it at                  }
  56.   Mov DX,Y                      {  Row to place it                      }
  57.   Int $10                       {  call dos                             }
  58. END;{BiosPutPix}
  59.  
  60. FUNCTION TSeng :BOOLEAN;
  61.                 {  Routine to determine if Graphics card is a TSENG labs}
  62. VAR
  63.         Old,New :BYTE;
  64. BEGIN
  65.   Old := Port[$3CD];            {  Save original card register value    }
  66.   Port[$3CD] := $55;            {  change it                            }
  67.   New := Port[$3CD];            {  read in new value                    }
  68.   Port[$3CD] := Old;            {  restore old value                    }
  69.   TSENG := ( New = $55 );       {  if value same as what we sent (TRUE) }
  70. END;
  71.  
  72. FUNCTION GetVideoMode :BYTE; ASSEMBLER;
  73.                       {  Routine to determine current video mode        }
  74. ASM
  75.   Mov AX,$0F00                  {  SubFunction Return Video Info        }
  76.   Int $10                       {  Call Dos                             }
  77. END;{GetVideoMode}
  78.  
  79. PROCEDURE Set80x30Mode;
  80. VAR CrtcReg:ARRAY[1..8] OF WORD;
  81.     Offset :WORD;
  82.     I,Data :BYTE;
  83. BEGIN
  84.   CrtcReg[1]:=$0C11;           {Vertical Display End (unprotect regs. 0-7)}
  85.   CrtcReg[2]:=$0D06;           {Vertical Total}
  86.   CrtcReg[3]:=$3E07;           {Overflow}
  87.   CrtcReg[4]:=$EA10;           {Vertical Retrace Start}
  88.   CrtcReg[5]:=$8C11;           {Vertical Retrace End (& protect regs. 0-7)}
  89.   CrtcReg[6]:=$DF12;           {Vertical Display Enable End}
  90.   CrtcReg[7]:=$E715;           {Start Vertical Blanking}
  91.   CrtcReg[8]:=$0616;           {End Vertical Blanking}
  92.  
  93.   MemW[$0040:$004C]:=8192;     {Change page size in bytes}
  94.   Mem[$0040:$0084]:=29;        {Change page length}
  95.   Offset:=MemW[$0040:$0063];   {Base of CRTRC}
  96.   ASM
  97.     Cli                        {Clear Interrupts}
  98.   END;
  99.  
  100.   FOR I:=1 TO 8 DO
  101.     PortW[Offset]:=CrtcReg[i]; {Load Registers}
  102.  
  103.   Data:=PORT[$03CC];
  104.   Data:=Data AND $33;
  105.   Data:=Data OR $C4;
  106.   PORT[$03c2]:=Data;
  107.   ASM
  108.    Sti                         {Set Interrupts}
  109.    Mov AH,12h                  {Select alternate printing routine}
  110.    Mov BL,20h
  111.    Int 10h
  112.   END;
  113. END; {Of Procedure}
  114.  
  115. PROCEDURE DrawBar( X1,Y1,X2,Y2 :WORD; Color :BYTE );
  116.                    { Bar drawing routine. Specifically set up for mode  }
  117.                    { 13h. Much faster than the BGI one.                 }
  118. VAR
  119.    Row     :WORD;
  120. BEGIN
  121.   FOR Row := Y1 TO Y2 DO
  122.     FillChar(MEM[$A000:(320*Row)+X1],X2-X1,Color);
  123. END;
  124.  
  125.  
  126. PROCEDURE SetColor( Color2Set, Red, Green, Blue :BYTE );
  127.                     { Routine to Change the palette value of Color2Set. }
  128. BEGIN
  129.     PORT[$3C8] := Color2Set;
  130.     PORT[$3C9] := Red;
  131.     PORT[$3C9] := Green;
  132.     PORT[$3C9] := Blue;
  133. END;
  134.  
  135. PROCEDURE GetColor( Color2Get :BYTE; VAR Red,Green,Blue :BYTE );
  136.                     { Routine to determine the Palette value of Color2Get}
  137. BEGIN
  138.     PORT[$3C8] := Color2Get;
  139.     Red := PORT[$3C9];
  140.     Green := PORT[$3C9];
  141.     Blue := PORT[$3C9];
  142. END;
  143.  
  144. BEGIN
  145. END.
  146.